﻿function insertPopup(parent) {
    var span = parent.find(".field-validation-error");
    span.hide();
    if (span.length == 0) {

    } else {
        parent.find("input").css("border", "2px solid red");
        parent.find("input").popover({ placement: "right", trigger: "hover", content: span.text(), title: "Błąd" });
    }
}

$(document).ready(function () {
    $("form > div").each(function () {
        insertPopup($(this));
    });

    if ($('.alert-info').find("li").text().length > 0) {
        var $inf = $('.alert-info').alert();
        setTimeout(function () {
            $inf.fadeOut(1500);
        }, 2500);
    } else {
        $('.alert-info').hide();
    }

    var $alert = $('.alert-error').alert();
    setTimeout(function() {
        $alert.fadeOut(1500);
    }, 2500);

});